<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 用户和项目中间表
 *
 * Date: 05/05/2018
 * @author George
 */
class UserProjectPivotTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_project_pivot', function (Blueprint $table) {
			$table->unsignedInteger('company_id')->index()->comment('公司ID');
			$table->unsignedInteger('project_id')->index()->comment('项目ID');
			$table->unsignedInteger('user_id')->index()->comment('用户ID');
            $table->string('type')->comment('关系类型');
            $table->timestamp('start')->nullable()->comment('开始时间');
            $table->timestamp('end')->nullable()->comment('开始时间');
            $table->timestamps();
            $table->primary(['company_id', 'project_id', 'user_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_project_pivot');
    }
}
